package com.attms.controller;

import com.attms.controller.utils.R;
import com.attms.domain.Absent;
import com.attms.domain.Employee;
import com.attms.service.IPersonnelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/personnel")
public class PersonnelController {
    @Autowired
    private IPersonnelService personnelService;

    @GetMapping
    public R getAllEmployeeBaseInfo(){
        return new R(true, personnelService.getAllInfo());
    }

    @GetMapping("{id}")
    public R getEmployeeByid(@PathVariable Integer id){
        return new R(true, personnelService.getInfoById(id));
    }

    @GetMapping("/report")
    public R getALLReportForms(){
        return new R(true, personnelService.getAllReport());
    }
    @PostMapping
    public R addEmployee(@RequestBody Employee employee){
        return new R(true, personnelService.add(employee));
    }

    @DeleteMapping("{id}")
    public R deleteEmployee(@PathVariable Integer id){
        return new R(true, personnelService.deleteById(id));
    }

    @PutMapping
    public R modifyEmployee(@RequestBody Employee employee){
        return new R(true, personnelService.modifyById(employee));
    }
    @PutMapping("/materials/{isagree}")
    //人事部审核假期材料
    public R solveLeave(@PathVariable("isagree")Integer isagree, @RequestBody Absent absent){
        return new R(true, personnelService.solveLeave(isagree, absent));

    }
}
